/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.machineryrental.weblayer.editors;

import cz.muni.fi.pa165.machineryrental.dto.MachineDTO;
import cz.muni.fi.pa165.machineryrental.service.MachineService;
import java.beans.PropertyEditorSupport;

/**
 *
 * @author jostri
 */
public class MachineEditor extends PropertyEditorSupport {
	
	private final MachineService machineService;
	
	public MachineEditor(MachineService machineService) {
		this.machineService = machineService;
	}
 
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		MachineDTO machine = this.machineService.getById(Long.parseLong(text));
		setValue(machine);
	}
	
}
